package com.song.mall.product.config;

import org.redisson.Redisson;


import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.redisson.config.Config;
import java.io.IOException;

/**
 * @author 宋超
 * HP - the login name of the current user.
 * 2021/9/25 - the current system date.
 * 15:49 - the current system time.
 */
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对Redisson的操作都要有一个RedissonClient对象
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod="shutdown")
    public RedissonClient redisson() throws IOException {
        // 创建配置
        Config config = new Config();
        // 单Redis节点模式 Redis url should start with redis:// or rediss:// (for SSL connection)
        config.useSingleServer().setAddress("redis://192.168.56.10:6379");
        //创建实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
